/**
 * @author n0skill
 */

function computeHit(player, weapon) {
	hitArrayIndex = player.ab - 1
	rollDice(player)
	if(p1dice != 1 &&  p2dice != 1) {
		if(player === player1) {
			console.log("dado per hittare " + p1dice)
			if(player2.cover == true) {
				hitArrayIndex -= 1;
			}
			if(player2.longRange == true) {
				hitArrayIndex -= 1;
			}
			if(player2.largeTarget == true) {
				hitArrayIndex += 1;
			}
			if(player1.isMoving == true) {
				hitArrayIndex -= 1;
			}
			p1shoot = hitArray[hitArrayIndex]
			if(p1dice >= p1shoot) {
				p1hit = true;
				rollToWound(player1, hammer)
			} else {
				p1hit = false;
				console.log("missed! <ab")
			}
		} else {
			console.log("dado per hittare " + p2dice)

			if(player1.cover == true) {
				hitArrayIndex -= 1;
			}
			if(player1.longRange == true) {
				hitArrayIndex -= 1;
			}
			if(player1.largeTarget == true) {
				hitArrayIndex += 1;
			}
			if(player2.isMoving == true) {
				hitArrayIndex -= 1;
			}
			p2shoot = hitArray[hitArrayIndex]
			if(p2dice >= p2shoot) {
				p2hit = true;
				rollToWound(player2, hammer)
			} else {
				p2hit = false;
			}
		}
	} else {
		p1hit = false;
		p2hit = false;
		console.log("missed! 1")
	}
}